(function() {
	var remote_server_url = "http://121.40.18.23:1518/api/complex/StoreFromMapFactory";

	var _ti;
	Path.on("/__basename__.html", function(_current_location) {
		var queryString = _current_location.query;
		var geotable_id = queryString.get("geotable_id");
		get_store_info(geotable_id).then(function(preview_data) {
			console.log(preview_data);
			var $movebox = $($(".movebox")[0]);
			$movebox.css({
				transform: "translateX(0)"
			});
			var len = ($(".bigimg")).length;
			var _init_i = 0;
			var str;
			clearInterval(_ti);
			_ti = setInterval(function() {
				str = "translateX(-" + ((_init_i % len) * 100) + "%)"
				$movebox.css({
					transform: str
				});
				_init_i += 1;
			}, 5000);
			App.set("$Event.store_preview.change_img", function(e, vm) {
				_init_i = vm.get("$Index");
				str = "translateX(-" + ((_init_i % len) * 100) + "%)"
				$movebox.css({
					transform: str
				});
			});
		});


	});

	// 获取店铺信息
	function get_store_info(store_id) {
		return new Promise(function(resolve, reject) {
			$.getJSON(remote_server_url, {
				geotable_id: store_id
			}, function(store_info) {
				store_info.store_imgs = store_info.store_imgs.split(",");
				App.set("$Cache.store_preview.store_info", store_info);
				resolve(store_info);
			});
		});
	};
	// 一键导航
	App.set("$Event.store_preview.navigation", function() {
		myConfirm("功能完善中！");
	});
	// 我的收藏
	App.set("$Event.store_preview.mycollections", function() {
		myConfirm("功能完善中！");
	});
}());